<template>
	<el-dialog title="菜单删除" :visible.sync="visible" width="500px" :center="false" :before-close="handleClose">
		<div slot="title" class="dialog-header-title">
			<i class="el-icon-edit" style="color: #FFF"></i>&nbsp;
			<span style="color: #FFF">菜单删除</span>
		</div>

		<div class="smp-search">
			<el-form :inline="false" label-width="100px" size="mini" ref="form" :model="form" :rules="rules">
				<el-row>
					<el-col :span="24">
						<el-form-item label="菜单名称:" prop="name">
							<el-input v-model="form.name"  placeholder="请输入菜单名称"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="菜单路径:" prop="path">
							<el-input v-model="form.path"  placeholder="请输入菜单路径"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="父菜单:" prop="parent">
							<el-input v-model="form.parent"  placeholder="请输入父菜单"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="菜单排序:" prop="menuOrder">
							<el-input v-model="form.menuOrder"  placeholder="请输入菜单排序"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="菜单级别:" prop="level">
							<el-input v-model="form.level"  placeholder="请输入级别"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
					<el-form-item label="状态:" prop="status" >
						<el-select v-model="form.status" placeholder="" style="width: 100%;">
							<el-option label="有效"value="1"></el-option>
							<el-option label="无效"value="0"></el-option>
						</el-select>
					</el-form-item>
					</el-col>
					<el-col :span="24">
					<el-form-item label="菜单类型:" prop="type" >
						<el-select v-model="form.type" placeholder="" style="width: 100%;">
							<el-option label="父菜单"value="1"></el-option>
							<el-option label="子菜单"value="0"></el-option>
						</el-select>
					</el-form-item>
					</el-col>
					
					<el-col :span="24">
						<el-form-item label="菜单图标:" prop="icon">
							<el-input v-model="form.icon" placeholder="请输入菜单图标"></el-input>
						</el-form-item>
					</el-col>
					
				</el-row>
			</el-form>
		</div>
		<span slot="footer" class="dialog-footer">
			<el-button @click="visible = false" size="mini">取 消</el-button>
			<el-button type="primary" @click="submit" size="mini">确 定</el-button>
		</span>
	</el-dialog>
</template>
<script>
	"use strict";
import {deleteMenu} from '@/api/menu.js';
	export default {
		data() {
			return {
				visible: false,
				form: {
					name: "",
					path: "",
					parent: "",
					type: "",
					level: "",
					menuOrder: "",
					status: "",
					icon:""
				},
				rules: {
					name: [{
						required: true,
						message: '请输入菜单名称',
						trigger: 'blur'
					}],
					path: [{
						required: true,
						message: '请输入菜单路径',
						trigger: 'blur'
					}],
					parent: [{
						required: true,
						message: '请输入父菜单',
						trigger: 'blur'
					}],
					type: [{
						required: true,
						message: '请输入菜单类型',
						trigger: 'blur'
					}],
					level: [{
						required: true,
						message: '请选择菜单级别',
						trigger: 'blur'
					}],
					menuOrder: [{
						required: true,
						message: '请输入菜单排序',
						trigger: 'blur'
					}],
					status: [{
						required: true,
						message: '请选择状态',
						trigger: 'blur'
					}],
				}
			}

		},
		methods: {
			ShowDialog(row) {
			   Object.assign(this.form,row);
				this.visible = true;
			},
			handleCancel(e) {
				this.visible = false;
			},
			submit() {
			this.$refs["form"].validate((valid)=>{
				if(valid){
					deleteMenu(this.form).then(response => {
						if(response.data.code == "0000"){
							this.$message.success(response.data.message);
						}else{
							this.$message.error(response.data.message);
						}
						
						
					}).catch(error => {
						this.$message.error(error.message);
					});
					this.visible = false;
					this.$emit("fresh")
				}
			});
			
		
				
			},
		}
	};
</script>
